<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui">
    <h:head>
        <title>Production Execution</title>
    </h:head>
    <h:form prependId="false">
        <p:growl id="notif" showDetail="true"/>  
        <h:body>
            <p:growl id="msgs" showDetail="true"/>
            <f:view beforePhase="#{UserDisplayManagedBean.initView}">
                <f:view beforePhase="#{ProductionExecutionManagedBean.initView}">

                    <!-- IDLE DIALOG for -->
                    <p:confirmDialog message="You have been idle for 5 minutes. Do you want to continue?"  
                                     showEffect="bounce" hideEffect="explode"  
                                     header="Warning message" severity="alert" widgetVar="confirmation">  
                        <p:commandButton value="Yes" onclick="confirmation.hide()" type="button" /> 
                        <p:commandButton value="No" update="panel" oncomplete="confirmation.hide()"  
                                         actionListener="#{UserManagedBean.doLogout}" /> 
                    </p:confirmDialog>

                    <p:idleMonitor timeout="300000" onidle="confirmation.show()" />  
                    <!--END OF IDLE DIALOG-->

                    <div id="header">
                        <h:graphicImage value="/image/newHeader.jpg"/>
                    </div>

                    <div id="content">
                        <table>
                            <tr>
                                <td style="vertical-align:top">
                                    <p:toolbar style="font-family: Tahoma;background-color:darkred;font-size:85%;height:33px;width:206px"> 
                                        <p:toolbarGroup align="right">
                                            <p:button title="Home" image="ui-icon-home" outcome="ManufacturingDeptWorkspace"/>
                                            <p:button title="Notes" image="ui-icon-note"/>
                                            <p:button title="Mail" image="ui-icon-mail-closed"/>
                                            <p:button title="Edit Preferences" image="ui-icon-gear"/>
                                            <p:button title="Help" image="ui-icon-help"/>
                                            <p:commandButton immediate="true" type="submit" image="ui-icon-close" actionListener="#{UserManagedBean.doLogout}"/> 
                                        </p:toolbarGroup>
                                    </p:toolbar>

                                    <p:menu id="menu" style="font-family: Tahoma; width:205px;height: 643px;font-family: Verdana;border-style: double;font-size: 80%">  
                                        <p:submenu label="Manufacturing Menu">  
                                            <p:menuitem value="Manufacturing Dept Home" url="http://localhost:8080/MerlionERP-war/MRP/ManufacturingDeptWorkspace.xhtml" ajax="false" icon="ui-icon ui-icon-home"/>  
                                        </p:submenu>
                                        <p:submenu label="Production Planning">
                                            <p:menuitem value="View Sales Record" url="http://localhost:8080/MerlionERP-war/MRP/SalesRecord.xhtml" ajax="false" icon="ui-icon ui-icon-search"/>  
                                            <p:menuitem value="View Sales Forecast" url="http://localhost:8080/MerlionERP-war/MRP/SalesForecast.xhtml" ajax="false" icon="ui-icon ui-icon-search" />
                                            <p:menuitem value="View Sales and Operation Plan" url="http://localhost:8080/MerlionERP-war/MRP/SalesAndOperationPlan.xhtml" ajax="false" icon="ui-icon ui-icon-search" />
                                        </p:submenu>
                                        <p:submenu label="Master Production Schedule">
                                            <p:menuitem value="View MPS Weekly" url="http://localhost:8080/MerlionERP-war/MRP/MasterProductionScheduleWeekly.xhtml" ajax="false" icon="ui-icon ui-icon-search" />
                                            <p:menuitem value="View MPS Daily" url="http://localhost:8080/MerlionERP-war/MRP/MasterProductionScheduleDaily.xhtml" ajax="false" icon="ui-icon ui-icon-search" />
                                            <p:menuitem value="Commit MPS" url="http://localhost:8080/MerlionERP-war/MRP/CommitMasterProductionSchedule.xhtml" ajax="false" icon="ui-icon ui-icon-search" />
                                        </p:submenu>
                                        <p:submenu label="Material Planning">
                                            <p:menuitem value="View Requirement Planning" url="http://localhost:8080/MerlionERP-war/MRP/MaterialRequirementPlanning.xhtml" ajax="false" icon="ui-icon ui-icon-search" />
                                        </p:submenu>
                                        <p:submenu label="Bill of Materials">
                                            <p:menuitem value="View Bill of Materials" url="http://localhost:8080/MerlionERP-war/MRP/BillOfMaterials.xhtml" ajax="false" icon="ui-icon ui-icon-search" />
                                        </p:submenu>
                                        <p:submenu label="Production Execution">
                                            <p:menuitem value="Production Execution" url="http://localhost:8080/MerlionERP-war/MRP/ProductionExecution.xhtml" ajax="false" icon="ui-icon ui-icon-search" />
                                        </p:submenu>
                                      </p:menu>
                                    <p:calendar mode="inline" style="font-size:11px;font-family:Tahoma"/>
                                </td>

                                <td style=" vertical-align: top">
                                    <h:graphicImage value="execution.gif" style="width:45px;height:35px" />
                                    <h:outputText value="         "/>
                                    <h:outputText value="Production Execution" style="font-family:Tahoma;font-size:20px;font-weight:bolder"/>
                                    <p:spacer width="100" height="10"/>
                                    <p:panel id="panel" style=" font-family: Tahoma;width:1122px;height:805px">
                                        <p:dataTable id="records" 
                                                     var="exec" value="#{ProductionExecutionManagedBean.pds}"                       
                                                     paginator="true" rows="5"
                                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                                     rowsPerPageTemplate="5,10,15"  style="font-size:70%;width:1050px;"
                                                     emptyMessage="No data found with given criteria" widgetVar="productionExecutionTable">  

                                            <f:facet name="header">
                                                <p:outputPanel style="text-align:right"  >
                                                    <h:outputText value="Search all fields:" style="margin-left:740px" />  
                                                    <p:inputText id="globalFilter" onkeyup="productionExecutionTable.filter()" style="right:-100px;width:150px" />  
                                                </p:outputPanel>
                                            </f:facet>

                                            <p:column headerText="Product Name" style="width: 100px" sortBy="#{exec.productName}" filterBy="#{exec.productName}" filterMatchMode="contains">
                                                <h:outputText value="#{exec.productName}"/>
                                            </p:column>

                                            <p:column headerText="Planned Quantity"  style="width: 100px">
                                                <h:outputText value="#{exec.dailyDemand}"/>
                                            </p:column>

                                            <p:column headerText="Adjusted Quantity"  style="width: 100px">
                                                <h:outputText value="#{exec.adjustedQty}"/>
                                            </p:column>

                                            <p:column headerText="Plan ID" style="width: 100px">
                                                <h:outputText value="#{exec.id}"/>
                                            </p:column>


                                        </p:dataTable>

                                        <p:commandButton ajax="true" value="Execute" onclick="dialog.show()"/>
                                        
                                        <!--DIALOG FOR EXECUTE-->
                                         <p:confirmDialog message="Do you want to execute the production plan?"  
                                                     showEffect="blind" hideEffect="explode"  
                                                     header="Production Execution" severity="alert" widgetVar="dialog">  
                                        <p:commandButton value="Yes" image="ui-icon ui-icon-wrench" update="panel records status" ajax="true" immediate="false" oncomplete="dialog.hide()"  
                                                         actionListener="#{ProductionExecutionManagedBean.doExecute}" />  
                                        <p:commandButton value="No" image="ui-icon ui-icon-close" onclick="dialog.hide()" type="button" />   
                                    </p:confirmDialog>  
                                        <h:outputText id="status" rendered="#{ProductionExecutionManagedBean.status}" value="Execution Status : SUCCESSFUL"/>

                                    </p:panel>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div id="footer">
                        <h:graphicImage value="/image/merlionfooter.jpg"/>
                    </div>
                </f:view>
            </f:view>
        </h:body>
    </h:form>
</html>

